using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(menuName = "Custom/ProjectileData")]
public class ProjectileData:ScriptableObject {

	public void OnEnable() {

		if(nameToData.ContainsKey(name)) return;

		_id=projectileData.Count+1;
		projectileData.Add(id,this);
		nameToData.Add(name,this);
	}

	int _id;
	public int id { get { return _id; } }
	[SerializeField] GameObject _prefab;

	public GameObject[] randomPrefabs;
	public GameObject prefab {
		get {
			if(randomPrefabs!=null&&randomPrefabs.Length>0) return randomPrefabs[Random.Range(0,randomPrefabs.Length)];
			return _prefab;
		}
	}

	public readonly static Dictionary<int,ProjectileData> projectileData = new Dictionary<int,ProjectileData>();
	public readonly static Dictionary<string,ProjectileData> nameToData = new Dictionary<string,ProjectileData>();
}
